#include "cuda.h"
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <iostream>
#include <cstdio>

__global__ void vecAdd(float* A, float* B, float* C)
{
	int i = threadIdx.x;
	C[i] = A[i] + B[i];

	printf("%f\n", C[i]);
}

int main()
{


	float A[] = {0,1,2,3,4,5};
	float B[] = {1,3,5,7,9,11};
	float C[6];

	float* d_A;
	float* d_B;
	float* d_C;

	size_t size = sizeof(A);

	cudaMalloc((void**)&d_A, size);
	cudaMalloc((void**)&d_B, size);
	cudaMalloc((void**)&d_C, size);

	cudaMemcpy(d_A, A, size, cudaMemcpyHostToDevice);
	cudaMemcpy(d_B, B, size, cudaMemcpyHostToDevice);

	vecAdd<<<1, 6>>>(d_A,d_B,d_C);

	cudaFree(d_A);
	cudaFree(d_B);
	cudaFree(d_C);

	std::cin.get();
}